<template>
  <div class="el-binMaterial">
    <TableTitle>
      <slot>
        <p>查询条件</p>
      </slot>
    </TableTitle>
    <ConditionSearch style="padding: 5px 0">
      <slot>
        <div class="tableSearch">
          <el-form :inline="true" :model="searchData" class="demo-form-inline">
          <el-form-item label=" 图号:">
            <el-input
                ref="saomaInput"
                size="mini"
                v-model="searchData.itemCode"
                placeholder="请输入内容"
              ></el-input>
          </el-form-item>
          <el-form-item label="AO编码:">
            <el-input
                ref="saomaInput"
                size="mini"
                v-model="searchData.aoCode"
                placeholder="请输入内容"
              ></el-input>
          </el-form-item>
          <el-form-item label="组号:">
            <el-input
                ref="saomaInput"
                size="mini"
                v-model="searchData.groupCode"
                :placeholder="maxNum"
              ></el-input>
          </el-form-item>

          <el-form-item label="是否标准件:">
            <el-select size="mini"  v-model="searchData.isBzj" placeholder="请选择">
              <el-option v-for="item in isBzjSelect" :key="item.value" :label="item.label" :value="item.value" > </el-option>
            </el-select>
          </el-form-item>

          <el-form-item label="单位:">
            <el-select size="mini"  v-model="searchData.shop" placeholder="请选择">
              <el-option v-for="item in shopList" :key="item.value" :label="item.label" :value="item.value" > </el-option>
            </el-select>
          </el-form-item>

          <el-form-item>
            <el-button type="primary" @click="searchBtn" size="mini">查询</el-button>
          </el-form-item>

        
            </el-form>

        </div>
      </slot>
    </ConditionSearch>
    <TableTitle>
      <slot>
        <p>编辑信息</p>
      </slot>
    </TableTitle>
    <TopBtn></TopBtn>
    <TableTitle>
      <slot>
        <p>缓存料箱物料表</p>
      </slot>
    </TableTitle>
    <TopTable></TopTable>
  </div>
</template>
<script>
import TopBtn from "./components/TopBtn.vue";
// import MidTabel from "./components/MidTableInfo.vue"
import TopTable from "./components/TopTable.vue";
import ConditionSearch from "../aacomponents/ConditionSearch.vue";
import TableTitle from "../../../../components/TableTitle.vue";
import { sysBbinMaterialSearch } from "@/utils/api.js";
import request from "@/utils/request.js";//yebo 添加
export default {
  name: "BinMaterial",
  components: {
    ConditionSearch,
    TableTitle,
    TopTable,
    TopBtn
  },
  data() {
    return {
        searchData:{
            workbinCode:'',
            itemCode:'',
            workbinName:'',
            aoCode:'',
            groupCode:'',
            isBzj:'',
            shop:''
        },
        isBzjSelect:[
            {
                value: "Y",
                label: "是",
            },
            {
                value: "N",
                label: "否",
            },
            {
                value: "",
                label: "所有",
            },
          ],
          shopList:[{
                value: "143",
                label: "143",
            },
            {
                value: "190",
                label: "190",
            },
            {
                value: "",
                label: "所有",
            }
            ],
        maxNum:"当前最大分组为:"+0,
        pageSize: 20,
        pageNumber: 1,
    };
  },
  methods:{
    // 查询
    searchBtn(){
      sysBbinMaterialSearch({
        searchParams:{
          // workbinCode:this.searchData.workbinCode,
          itemCode:this.searchData.itemCode,
          aoCode:this.searchData.aoCode,
          isBzj:this.searchData.isBzj,
          shop:this.searchData.shop,
          groupCode:this.searchData.groupCode,
          // workbinName:this.searchData.workbinName,
        },
        pageParameter:{
          rows:this.pageSize,
          page:1
        }
      }).then((res)=>{
        console.log('查询按钮',res)
        if(res.data.retCode == 200){
          this.$Alert({
              title: "成功",
              message: res.data.message,
              type: "success",
          });
          // 查询成功将数据给Table
          this.$bus.$emit('sysBbMaterialTable',res.data.responseBody)
        }else {
          this.$bus.$emit('sysBbMaterialTable',res.data.responseBody)
            this.$Alert({
                title: "失败",
                message: res.data.message,
                type: "error",
            });
        }
      })
    },
    queryMaxGroup(){
       //yebo 添加初始化最大分组
      request.post("/workbinMaterialMaintain/queryMaxGroup",{}).then((res=>{
        console.log("res",res);
        this.maxNum = "当前最大分组为:"+res.data.retData.maxNum;
      }));
    }
  },
  mounted(){
    this.$bus.$on('sysBbPageNumber',(e)=>{
      this.pageNumber = e
    })

    this.$bus.$on('sysBbPageSize',(e)=>{
      this.pageSize = e
    })
    this.$bus.$on("reloadMaxGroup",(e)=>{
      this.$options.methods.queryMaxGroup.bind(this)();
    });

    //yebo 初始化最大分组
    this.$options.methods.queryMaxGroup.bind(this)();

    // 修改刷新Table并定位页数
  }
};
</script>
<style scoped>
.tableSearch {
  position: relative;
}
.tableSearch ul {
  overflow: hidden;
}
.tableSearch ul li {
  float: left;
  width: 21%;
  height: 30px;
  line-height: 30px;
  margin-right: 1%;
  margin-bottom: 5px;
  overflow: hidden;
}
.tableSearch ul li span {
  float: right;
}
.tableSearch ul li div {
  float: right;
}
.el-input {
  width: 180px;
}
.el-select {
  width: 180px;
}

.searchBtnBox {
  position: absolute;
  top: 0;
  right: 50px;
}
</style>